package 优先算法.位运算.只出现一次的数字II;

/**
 * https://leetcode.cn/problems/single-number-ii/description/
 */
public class Main {
    public static void main(String[] args) {
        Solution so = new Solution();
        int[] arr = {0,1,0,1,0,1,99};
        int rel = so.singleNumber(arr);
        System.out.println(rel);
    }
}
class Solution {
    public int singleNumber(int[] nums) {
        int rel = 0;

        for(int i = 0 ; i < 32 ; i++){
            int sum = 0;
            for(int x : nums){
                if(((x >> i) & 1) == 1){
                    sum++;
                }
            }
            sum %=3;
            if(sum == 1){
                rel = rel | (sum << i);
            }
        }
        return rel;
    }
}
